import type { FieldConfig } from '@/components/TableFilter.vue'
import { getFormFields } from '@/utils/formUtils'
import type { FormFieldConfig } from '@/types/form'

// 表格列配置
export const tableColumns = [
  {
    title: 'ID',
    dataIndex: 'id',
  },
  {
    title: '方案標題',
    dataIndex: 'title',
  },
  {
    title: '修改人',
    dataIndex: 'updatedBy',
  },
  {
    title: '修改時間',
    dataIndex: 'updatedAt',
  },
  {
    title: '操作',
    key: 'action',
    align: 'center',
  },
]
// 過濾項配置
export const filterFields: FieldConfig[] = [
  {
    name: 'title',
    label: '方案標題',
    type: 'input',
    placeholder: '請輸入方案標題',
  },
]

// 表單字段配置
const FormField: Record<string, FormFieldConfig> = {
  title: {
    label: '方案標題',
    type: 'input',
    placeholder: '請輸入方案標題',
    rules: [{ required: true, message: '請輸入方案標題' }],
  },
}

export const getCreteFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}

export const getEditFieldConfig = (fields?: string[]) => {
  return getFormFields(FormField, fields)
}
